package com.wkh.datastructure.DeleteNode;

//根据值删除节点
public class demo2 {

    public static void main(String[] args) {
        ListNode node4 = new ListNode(null, 4);
        ListNode node3 = new ListNode(node4, 3);
        ListNode node2 = new ListNode(node3, 2);
        ListNode node1= new ListNode(node2, 1);
        ListNode newNode = delete(2,node1);
    }
    public static ListNode delete(int value,ListNode p){
        if (p == null){
            return null;
        }
        if (p.value == value){
            return delete(value,p.next);
        }else{
            p.next = delete(value,p.next);
            return p;
        }
    }
}
